from tortoise import models, fields
from tortoise.contrib.pydantic import pydantic_model_creator
from enum import IntEnum, Enum


class CookMethod(str, Enum):
    noodle = "noodle"
    soup = "soup"
    stir_fry = "stir_fry"
    deep_fry = "deep_fry"
    grill = "grill"
    bake = "bake"
    boil = "boil"
    stew = "stew"
    # noodle = "面条"
    # soup = "汤"
    # stir_fry = "快炒"
    # deep_fry = "油炸"
    # grill = "烤"
    # bake = "烘焙"
    # boil = "滚煮"
    # stew = "炖"


class TestResult(IntEnum):
    failure = 0
    partial = 1
    success = 2


class DishComplexity(IntEnum):
    easy = 1
    moderate = 3
    challenging = 4
    hard = 5
    complex = 6


class Dish(models.Model):
    Name = fields.CharField(max_length=100, unique=True)
    NameCN = fields.CharField(max_length=100, unique=True)
    Complexity = fields.IntEnumField(DishComplexity)
    Keypoint = fields.TextField()
    Method = fields.CharEnumField(CookMethod)
    Success = fields.IntEnumField(TestResult)

    class Meta:
        table = "dish"
        ordering = ["-id"]
        # unique_together = (("field_a", "field_b"),)


dishIn_pydantic = pydantic_model_creator(Dish, name="dish_in", exclude_readonly=True)
dishOut_pydantic = pydantic_model_creator(Dish, name="dish_out")
# noteOut_pydantic = pydantic_model_creator(Note, name='note_out', exclude=('id',))
# productIn_pydantic = pydantic_model_creator(Product,  name='product_in', exclude=('id', 'revenue'))
# productOut_pydantic = pydantic_model_creator(Product, name='product_out')

# supplierIn_pydantic = pydantic_model_creator(Supplier, name='supplier_in', exclude_readonly=True)
# supplierOut_pydantic = pydantic_model_creator(Supplier, name='supplier_out')


# class Info(models.Model):
#     id = fields.IntField(pk=True)
#     body = fields.TextField()
#     add_date = fields.DatetimeField(auto_now_add=True)

#     class Meta:
#         ordering = ["-id"]


# infoIn_pydantic = pydantic_model_creator(Info, name="info_inf", exclude=("id", "add_date"))
# infoOut_pydantic = pydantic_model_creator(Info, name="info_out")
